class JdnbbController < ApplicationController	

  layout "mainlayout"
  
	before_filter :login_required, :only => [ :home]	
	before_filter :login_from_cookie
	
	def index
    desktop(false)
		render :action => 'desktop'
	end
		
	def home
		render :action => 'home' , :layout => false
	end

	def desktop(r = true)
		@encuentros = Encuentro.find(:all, :order  => "fecha DESC"  )
    @delegaciones = Delegacion.find(:all, :order => "oro DESC" )
    @records = Record.find(:all, :order => "fecha DESC", :conditions => "nuevo='t'" )
 		@noticias = Noticia.find(:all, :order  => "fecha DESC"  )
    
		@deportistas = Deportista.find(:all)
		@equipos = Equipo.find(:all)
		render :action => 'desktop' , :layout => false if r
	end
  
  def listar_encuentros
		@encuentros = Encuentro.find(:all, :order  => "fecha DESC"  )
    render( :partial => 'listar_encuentros', :locals => {:title => "Listado de encuentros", :encuentros => @encuentros, :action_more=>nil}, :layout => false)
  end
  
  def listar_records
    @records = Record.find(:all, :order => "fecha DESC" )
    render( :partial => 'listar_records', :locals => {:title => "Records records", :records => @records, :action_more=>nil}, :layout => false)
  end
		
  def noticias
    @noticias = Noticia.find(:all, :order  => "fecha DESC"  )
    render( :partial => 'noticias', :locals => {:noticias => @noticias, :size => 0}, :layout => false)
  end
  
	def init
		render :action => 'home'
	end
  
  def reportes
    render :action => 'reportes', :layout => false 
  end
  
  def generar_reporte
    @tipo = params[:tipo_grafico] if params[:tipo_reporte] == "grafico"
    @descripcion = params[:descripcion]
    if params[:tipo_reporte] == "grafico"
      render :action => 'generar_reporte_grafico', :layout => false 
    else
#    redirect_to :action => 'generar_pdf', :controller => 'reportes', :id =>  1
           render :action => 'generar_reporte_pdf', :layout => false
    end
  end
  
  def cambiar_panel_reporte
     @tipo = params[:tipo_reporte]
  end
  
  def delegaciones_xml
    @delegaciones = Delegacion.find(:all, :order => "oro DESC" )
    render :layout =>false
  end
  
  private
  
end
